package com.event.core.util;

import java.util.Objects;

/**
 * @Description 开关上下文
 * @Author Bing
 * @Date 2024/10/29 10:39
 */
public class RepoSwitchContext {

    private static final ThreadLocal<Boolean> REPO_SWITCH = new ThreadLocal<>();

    public static void set(Boolean value) {
        REPO_SWITCH.set(value);
    }

    public static boolean get() {
        Boolean value = REPO_SWITCH.get();
        if(Objects.isNull(value)){
            return true;
        }
        return REPO_SWITCH.get();
    }

    public static void remove() {
        REPO_SWITCH.remove();
    }
}